package online.sixfish.common.utils;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateTimeUtils {
    private static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static String format(Date date){
        return format(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
    }
    public static String format(LocalDateTime dateTime) {
        return format(dateTime, DEFAULT_FORMATTER);
    }


    public static String format(LocalDateTime dateTime, DateTimeFormatter formatter) {
        return dateTime.format(formatter);
    }
}
